package com.weareint.common.utils;

import com.google.common.cache.LoadingCache;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.ExecutionException;

@Slf4j
public class CacheUtil {

    public static Object getObjectFromCache(String key, LoadingCache loadingCache) {
        try {
            return loadingCache.get(key);
        } catch (ExecutionException e) {
            if (log.isErrorEnabled()) {
                log.error("Can not found the value from local cache.", e);
            }
            return null;
        }
    }
}
